package touchtrack.model.track;

import java.awt.Image;

import touchtrack.exception.IllegalDuplicationException;
import touchtrack.model.artist.Artist;

/**
 * Factory method pattern.
 * Creates a Track object of the appropriate type.
 * 
 * @author	MuMe09 team 6
 * 			http://mumetech.wordpress.com/
 */
public class TrackFactory
{
	/**
	 * Creates a Track object.
	 * 
	 * @param 	Artist artist
	 * @param 	String title
	 * @param	String image
	 * @param 	String type
	 * @param	String mp3path (null if external track)
	 * @return	Track
	 * @throws 	IllegalDuplicationException
	 */
	public static Track createTrack(Artist artist, String title, Image image, String type, String mp3path) 
		throws IllegalDuplicationException
	{
		// Check type & create Track.
		if (type.toLowerCase().equals("local"))
		{
			return new LocalTrack(artist, title, image, mp3path);
		}
		else if (type.toLowerCase().equals("external"))
		{
			return new ExternalTrack(artist, title, image);
		}
		else
		{
			// default
			return new ExternalTrack(artist, title, image);
		}
	}
}